package com.cpecc.dao.system;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.cpecc.model.system.Root;

@Repository
public class RootDao {
	
	@Resource
	private SessionFactory sessionFactory;
	
	public String getRoot(){
		String hql="from Root t";
		Query query=sessionFactory.getCurrentSession().createQuery(hql);
		if(query.list().size()>0)
			return ((Root)query.list().get(0)).getPath();
		else
			return "";
	}
	
	public String getRoot2(){
		String result="";
		String hql="from Root t";
		Session session=sessionFactory.openSession();
		Query query=session.createQuery(hql);
		if(query.list().size()>0)
			result=((Root)query.list().get(0)).getPath();
		session.close();
		return result;
	}
}
